package play.modules.facebook;

import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import play.exceptions.UnexpectedException;

import java.util.HashMap;
import java.util.Map;

/**
 * Wrapper around signed request map
 * User: dallan
 */
public class SignedRequest {
   private Map<String,String> data;

   public SignedRequest(JsonElement json) {
      try {
         data = Utils.jsonToMap(json);
      }
      catch (JsonParseException e) {
         throw new UnexpectedException("Unexpected signed request: "+json.getAsString());
      }
   }

   public String getUid() {
      return data.get("user_id");
   }

   public String getOauthToken() {
      return data.get("oauth_token");
   }

   public String getExpires() {
      return data.get("expires");
   }

   public String getAlgorithm() {
      return data.get("algorithm");
   }
}
